package com.tanhua.dubbo.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.SettingsMapper;
import com.tanhua.model.domain.mysql.Settings;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SettingsApiImpl implements SettingsApi {

    @Autowired
    private SettingsMapper settingsMapper;

    @Override
    public Settings findSettings(Long userId) {
        LambdaQueryWrapper<Settings> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Settings::getUserId,userId);
        return settingsMapper.selectOne(queryWrapper);
    }

    @Override
    public void saveSettings(Settings findSettings) {
        settingsMapper.insert(findSettings);
    }

    @Override
    public void updateSettings(Settings findSettings) {
        settingsMapper.updateById(findSettings);
    }


}